<?php if ( ! defined('BASEPATH')) exit('No direct script schess allowed'); ?>

<?=form_hidden("art_id", (isset($getArticle[0]["artId"]) ? $getArticle[0]["artId"] : 0))?>

<div class="form-group">
	<?=form_label($this->lang->line("TITLE_OF_ARTICLE"), "art_name", array("class" => "control-label"))?>
	<?=form_input("art_name", (isset($getArticle[0]["artName"]) ? $getArticle[0]["artName"] : null), "placeholder=\"".$this->lang->line("TITLE_OF_ARTICLE")."\" class=\"form-control\" id=\"art_name\"")?>
</div>

<div class="form-group">
	<?=form_label($this->lang->line("LEAD"), "art_lead", array("class" => "control-label"))?>
	<?=form_textarea("art_lead", (isset($getArticle[0]["artLead"]) ? $getArticle[0]["artLead"] : null), "placeholder=\"".$this->lang->line("LEAD")."\" class=\"form-control\" id=\"art_lead\"")?>
	<script>
		$(function() {
			CKEDITOR.replace('art_lead').on('instanceReady',function(){
				$('#studyEditorModal .modal-body form').resize();
			});
		});
	</script>
</div>

<div class="form-group">
	<?=form_label($this->lang->line("TEXT"), "art_text", array("class" => "control-label"))?>
	<?=form_textarea("art_text", (isset($getArticle[0]["artText"]) ? $getArticle[0]["artText"] : null), "placeholder=\"".$this->lang->line("TEXT")."\" class=\"form-control\" id=\"art_text\"")?>
	<script>
		$(function() {
			CKEDITOR.replace('art_text').on('instanceReady',function(){
				$('#studyEditorModal .modal-body form').resize();
			});
		});
	</script>
</div>

<? if(Common::isSuperAdmin()) { ?>

	<div class="form-group">
		<?=form_label($this->lang->line("POSITION"), "art_position", array("class" => "control-label"))?>
		<? $szotar = Common::szotar("ARTPOS"); ?>
		<?=form_dropdown("art_position", $szotar["ARTPOS"], (isset($getArticle[0]["artPosition"]) ? $getArticle[0]["artPosition"] : null), "style=\"width:100%;\" id=\"art_position\"")?>
		<script>
			$(function() {
				$('#art_position').select2({
					placeholder: '<?=$this->lang->line("POSITION")?>',
				});
			});
		</script>
	</div>

	<div class="checkbox">
		<label>
			<input name="art_highlight" type="checkbox" <?=((isset($getArticle[0]["artHighlight"]) and $getArticle[0]["artHighlight"] == "I") ? "checked" : "")?>> <?=$this->lang->line("EMPHASIZED")?>
		</label>
	</div>

<? } ?>

<? if(Common::isAdminJog("COU")) { ?>

	<div class="form-group">
		<?=form_label($this->lang->line("ORSZAGHOZ"), "cou_id", array("class" => "control-label"))?>
		<?=form_dropdown("cou_id[]", $getCountryList, (isset($getArticle[0]["couList"]) ? explode(",", $getArticle[0]["couList"]) : null), "id=\"cou_id\" style=\"width: 100%;\" multiple")?>
		<script>
			$(function() {
				$('#cou_id').select2({
					placeholder: '<?=$this->lang->line("ORSZAGHOZ")?>',
				});
			});
		</script>
	</div>

<? } ?>

<h4><?=$this->lang->line("ATTACH_OF_THE_ARTICLE")?></h4>

<? if(Common::isAdminJog("COU") or Common::isAdminJog("CITY")) { ?>

	<div class="form-group">
		<?=form_label($this->lang->line("FOR_CITY"), "city_id", array("class" => "control-label"))?>
		<?=form_input("city_id[]", (isset($getArticle[0]["cityList"]) ? $getArticle[0]["cityList"] : null), "style=\"width:100%;\" id=\"city_id\"")?>
		<script>
			$(function() {
				$('#city_id').select2({
					allowClear: true,
					multiple: true,
					placeholder: '<?=$this->lang->line("FOR_CITY")?>',
					minimumInputLength: 2,
					ajax: {
						url: '<?=site_url("admin_lte/get_city")?>',
						cache: false,
						dataType: 'json',
						data: function (term, page) {
							return {
								q: term
							};
						},
						results: function (data, page) {
							return {results: data, more: false};
						}
					},
					initSelection: function(element, callback) {
						var id=$(element).val();
						if (id!=="") {
							$.ajax('<?=site_url("admin_lte/get_city")?>', {
								data: {
									id: id
								},
								cache: false,
								dataType: "json"
							}).done(function(data) { callback(data); });
						}
					},
					formatSelection: function(a, b, c) {
						if($.isArray(a)) {
							return a[0].text;
						}
						return a.text;
					},
					escapeMarkup: function (m) { return m; }
				});
			});
		</script>
	</div>

<? } ?>

<? if(Common::isAdminJog("INS")) { ?>

	<div class="form-group">
		<?=form_label($this->lang->line("TO_THE_INSTITUTE"), "ins_id", array("class" => "control-label"))?>
		<?=form_dropdown("ins_id[]", $getInstituteList, (isset($getArticle[0]["insList"]) ? $getArticle[0]["insList"] : null), "id=\"ins_id\" style=\"width: 100%;\" multiple")?>
		<script>
			$(function() {
				$('#ins_id').select2({
					placeholder: '<?=$this->lang->line("TO_THE_INSTITUTE")?>',
				});
			});
		</script>
	</div>

<? } ?>

<div class="form-group">
	<?=form_label($this->lang->line("TO_THE_SUBJECT"), "sub_id", array("class" => "control-label"))?>
	<select id="sub_id" name="sub_id[]" style="width:100%;" multiple>
		<option value=""></option>
		<? 
		foreach($getSubjectList as $par) {
			echo	"<optgroup label=\"".$par["subName"]."\">";
			foreach($par["children"] as $child) {
				echo		"<option value=\"".$child["subId"]."\">".$child["subName"]."</option>";
			}
			echo	"</optgroup>";
		}
		?>
	</select>
	<script>
		$(function() {
			$('#sub_id').select2({
				placeholder: '<?=$this->lang->line("TO_THE_SUBJECT")?>',
			});
		});
	</script>
</div>

<div class="form-group">
	<?=form_label($this->lang->line("TO_THE_COURSE"), "maj_id", array("class" => "control-label"))?>
	<?=form_dropdown("maj_id[]", $majorList, (isset($getArticle[0]["majList"]) ? $getArticle[0]["majList"] : null), "id=\"maj_id\" style=\"width: 100%;\" multiple")?>
	<script>
		$(function() {
			$('#maj_id').select2({
				placeholder: '<?=$this->lang->line("TO_THE_COURSE")?>',
			});
		});
	</script>
</div>